#include "ik_ISound.h"
#include <irrKlang.h>

static irrklang::ISoundEngine* soundEngine = 0;

#ifdef __cplusplus
extern "C" {
#endif
#include "audio.h"

static irrklang::ISound* sound = nullptr;

void copi_audio_open()
{
    soundEngine = irrklang::createIrrKlangDevice();
}

void copi_audio_close()
{
    soundEngine->drop();
}

void copi_audio_stop()
{
    if ( nullptr == sound ) return;
    sound->stop();
    sound->drop();

    sound = nullptr;
}

void copi_audio_play( const char* fileName, bool loop )
{
    sound = soundEngine->play2D( fileName, loop, false, true );
    if( nullptr != sound)
    {
    }
}

#ifdef __cplusplus
}
#endif
